package com.bing.picture;

import static com.bing.util.AssertUtils.notBlank;

public enum PictureFormat {
	
	UNKNOW(false),
	
	PNG(true),
	
	JPG(true),
	
	JPEG(true),
	
	BMP(false),
	
	GIF(false),
	
	SVG(false);
	
	public static final PictureFormat[] PICTURE_FORMATS = PictureFormat.values();

	private boolean supported;
	
	private PictureFormat(boolean supported) {
		this.supported = supported;
	}
	
	public static PictureFormat getPictureFormat(String format) {
		
		notBlank(format, "format must not be null!");
		for (PictureFormat pictureFormat : PictureFormat.PICTURE_FORMATS) {
			if(pictureFormat.name().equals(format.toUpperCase())) {
				return pictureFormat;
			}
		}
		return PictureFormat.UNKNOW;
	}

	public boolean isSupported() {
		return supported;
	}
	
}
